from common.token01 import login
from api.ihrm_ import Ihrm
from common import assert_tools
from common.mysql_ import DB_Tool
class TestPost:
    def setup_class(self):
        delete  = DB_Tool().iud("delete from bs_user where mobile = '13512345678'")
        return delete
    def teardown(self):
        delete = DB_Tool().iud("delete from bs_user where mobile = '13512345678'")
        return delete
    def test01(self):
        a = Ihrm()
        req_headers = login()
        req_body = {"username": "user87655430","mobile": "13512345678", "workNumber": "9527890aa"}
        resp = a.ihrm_post(req_headers,req_body)
        print("添加成功",resp.json())
        assert_tools.assert_tools(resp, 200, True,10000,"操作成功")
    def test02(self):
        a = Ihrm()
        req_headers = login()
        req_body = {"username": "user87655430",
                         "mobile": "13800000002",
                         "workNumber": "9527890aa"}
        resp = a.ihrm_post(req_headers,req_body)
        print("手机号已注册",resp.json())
        assert_tools.assert_tools(resp, 200, False,20002,"新增")
    def test03(self):
        a = Ihrm()
        req_headers = login()
        req_body = {"username": None,
                         "mobile": "13512345678",
                         "workNumber": "9527890aa"}
        resp = a.ihrm_post(req_headers,req_body)
        print("用户名空",resp.json())
        assert_tools.assert_tools(resp, 200, False,20002,"新增")
    def test04(self):
        a = Ihrm()
        req_headers = login()
        req_body = {"username": 123456,
                         "mobile": 13512345678,
                         "workNumber": None}
        resp = a.ihrm_post(req_headers,req_body)
        print("手机号空",resp.json())
        assert_tools.assert_tools(resp, 200, False,20002,"新增")
    def test05(self):
        a = Ihrm()
        req_headers = login()
        req_body = {"username": 123456,
                         "mobile": None,
                         "workNumber": "9527890aa"}
        resp = a.ihrm_post(req_headers,req_body)
        print("工号空",resp.json())
        assert_tools.assert_tools(resp, 200, False,20002,"新增")
